<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加广告</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-4">
    <h1>添加广告</h1>
    <a href="/admin/ads" class="btn btn-secondary mb-3">返回列表</a>
    <a href="/admin/categories" class="btn btn-info mb-3 ms-2">分类管理</a>

    <form th:action="@{/admin/ads/save}" method="post" enctype="multipart/form-data">
        <div class="mb-3">
            <label for="name" class="form-label">广告名称</label>
            <input type="text" class="form-control" id="name" name="name" required>
        </div>

        <div class="mb-3">
            <label for="categoryId" class="form-label">广告分类</label>
            <select class="form-control" id="categoryId" name="categoryId" required>
                <option value="">请选择分类</option>
                <option th:each="category : ${categories}"
                        th:value="${category.id}"
                        th:text="${category.name}"></option>
            </select>
        </div>

        <div class="mb-3">
            <label for="imageFile" class="form-label">广告图片</label>
            <input type="file" class="form-control" id="imageFile" name="imageFile" required>
        </div>

        <div class="mb-3">
            <label for="linkUrl" class="form-label">链接地址</label>
            <input type="url" class="form-control" id="linkUrl" name="linkUrl">
        </div>

        <div class="mb-3">
            <label for="status" class="form-label">状态</label>
            <select class="form-control" id="status" name="status">
                <option value="1">启用</option>
                <option value="0">禁用</option>
            </select>
        </div>

        <button type="submit" class="btn btn-primary">保存</button>
    </form>
</div>
</body>
</html>